package com.probiz.estore.common.model.system.base;

import java.io.Serializable;
import java.util.Map;
import java.util.HashMap;
import com.probiz.estore.core.model.BaseObject;
import org.apache.commons.lang.builder.HashCodeBuilder;
import org.apache.commons.lang.builder.ToStringBuilder;
import org.apache.commons.lang.builder.EqualsBuilder;

/**
 * AppUserRole Base Java Bean, base class for the model, mapped directly to database table
 * 
 * Avoid changing this file if not necessary, will be overwritten. 
 *
 */
public class AppUserRoleTbl extends BaseObject implements Serializable {

	protected AppUserRolePK appUserRolePK = new AppUserRolePK();
	protected com.probiz.estore.common.model.system.AppUser appUser;
	protected com.probiz.estore.common.model.system.AppRole appRole;


	/**
	 * Default Empty Constructor for class AppUserRole
	 */
	public AppUserRoleTbl () {
		super();
	}
	
	/**
	 * Default Key Fields Constructor for class AppUserRole
	 */
	public AppUserRoleTbl (
		 Integer in_roleId
		,Integer in_appuserId
        ) {
		this.setRoleId(in_roleId);
		this.setAppuserId(in_appuserId);
    }

	
	public com.probiz.estore.common.model.system.AppUser getAppUser () {
		return appUser;
	}	
	
	public void setAppUser (com.probiz.estore.common.model.system.AppUser in_appUser) {
		this.appUser = in_appUser;
	}
	
	public com.probiz.estore.common.model.system.AppRole getAppRole () {
		return appRole;
	}	
	
	public void setAppRole (com.probiz.estore.common.model.system.AppRole in_appRole) {
		this.appRole = in_appRole;
	}
  /**
	* @return appUserRolePK
	*/
	public AppUserRolePK getAppUserRolePK() {
		return this.appUserRolePK;
	}
	
  /**
	* @set appUserRolePK
	*/
	public void setAppUserRolePK(AppUserRolePK aPrimaryKey) {
		this.appUserRolePK = aPrimaryKey;
	}
    

	/**
	 * 	 * @return Integer
     * @hibernate.id column="roleId" type="java.lang.Integer" generator-class="native"
	 */
	public Integer getRoleId() {
		return this.getAppUserRolePK().getRoleId();
	}
	
	/**
	 * Set the roleId
	 */	
	public void setRoleId(Integer aValue) {
	    if (aValue==null) {
	    	appRole = null;
	    } else {
	        appRole = new com.probiz.estore.common.model.system.AppRole(aValue);
	        appRole.setVersion(Integer.valueOf(0));//set a version to cheat hibernate only
	    }
		this.getAppUserRolePK().setRoleId(aValue);
	}	

	/**
	 * 	 * @return Integer
     * @hibernate.id column="appuserId" type="java.lang.Integer" generator-class="native"
	 */
	public Integer getAppuserId() {
		return this.getAppUserRolePK().getAppuserId();
	}
	
	/**
	 * Set the appuserId
	 */	
	public void setAppuserId(Integer aValue) {
	    if (aValue==null) {
	    	appUser = null;
	    } else {
	        appUser = new com.probiz.estore.common.model.system.AppUser(aValue);
	        appUser.setVersion(Integer.valueOf(0));//set a version to cheat hibernate only
	    }
		this.getAppUserRolePK().setAppuserId(aValue);
	}	

	/**
	 * @see java.lang.Object#equals(Object)
	 */
	public boolean equals(Object object) {
		if (!(object instanceof AppUserRoleTbl)) {
			return false;
		}
		AppUserRoleTbl rhs = (AppUserRoleTbl) object;
		return new EqualsBuilder()
				.append(this.appUserRolePK.roleId, rhs.appUserRolePK.roleId)
				.append(this.appUserRolePK.appuserId, rhs.appUserRolePK.appuserId)
				.isEquals();
	}

	/**
	 * @see java.lang.Object#hashCode()
	 */
	public int hashCode() {
		return new HashCodeBuilder(-82280557, -700257973)
				.append(this.appUserRolePK.roleId) 
				.append(this.appUserRolePK.appuserId) 
				.toHashCode();
	}

	/**
	 * @see java.lang.Object#toString()
	 */
	public String toString() {
		return new ToStringBuilder(this)
				.append("roleId", this.appUserRolePK.roleId) 
				.append("appuserId", this.appUserRolePK.appuserId) 
				.toString();
	}

	/**
	 * Return the name of the first key column
	 */
	public String getFirstKeyColumnName() {
		return "roleId";
	}

	/**
	 * Return the primary key as a hashmap
	 */
	public Map getPrimaryKeyMap() {
		
		Map pkMap = new HashMap();
	    pkMap.put("roleId",   this.getRoleId());
	    pkMap.put("appuserId",   this.getAppuserId());
		return pkMap;
	}

	/**
	 * Return the primary key String as key value pairs
	 */
	public String getPrimaryKeyString() {
		
		java.lang.StringBuffer pkeyString = new java.lang.StringBuffer("[");
	    pkeyString.append("roleId=");
	    pkeyString.append(this.getRoleId());
		pkeyString.append(",");
	    pkeyString.append("appuserId=");
	    pkeyString.append(this.getAppuserId());
	    pkeyString.append("]");
		return pkeyString.toString();
	}
}